let that = null
let catalogueList = []
let pageItems = []
// 左侧目录
for (let i = 0; i < 13; i++) {
  catalogueList.push({
    className: 'catalogue',
    styleObj: {
      top: `${(53.3 + (i * 1.94)).toFixed(3)}%`,
      left: '53.6%',
      height: '1.7%'
    },
    index: i,
    onClick: function (obj) {
      if (that.pages[obj.index + 2]) {
        that.currentPagesNum = obj.index + 2
      } else {
        that.currentPagesNum = that.pages.length - 1
      }
    }
  })
}
// 右侧目录
for (let i = 0; i < 13; i++) {
  catalogueList.push({
    className: 'catalogue',
    styleObj: {
      top: `${(53.3 + (i * 1.94)).toFixed(3)}%`,
      left: '69.6%',
      height: '1.7%'
    },
    index: 13 + i,
    onClick: function (obj) {
      if (that.pages[obj.index + 2]) {
        that.currentPagesNum = obj.index + 2
      } else {
        that.currentPagesNum = that.pages.length - 1
      }
    }
  })
}
// 循环生成内容页 pageItems
for (let i = 0; i < 26; i++) {
  let num = i + 2
  pageItems.push({
    leftSubject: `case2/P${num}-01`,
    rightSubject: `case2/P${num}-02`,
    showPageText: `P${(i + 1) * 2 - 1}-P${(i + 1) * 2}`,
    leftAnswer: `case2/P${num}-01-an`,
    rightAnswer: `case2/P${num}-02-an`,
    hotmap: [
      // 解答按钮1
      {
        className: 'answer',
        img: 'common/answerButton',
        styleObj: {
          left: '40%'
        },
        onClick: function () {
          that.currentLeftType = that.currentLeftType == 'answer' ? 'subject' : 'answer'
        }
      },
      // 解答按钮2
      {
        className: 'answer',
        img: 'common/answerButton',
        styleObj: {
          left: '60%'
        },
        onClick: function () {
          that.currentRightType = that.currentRightType == 'answer' ? 'subject' : 'answer'
        }
      },
      // 声音1
      {
        className: 'sound',
        img: 'common/soundButton',
        styleObj: {
          top: '12%',
          left: '11.8%'
        },
        audioSrc: `case2/P${num}-01`,
        onClick: function (obj) {
          that.doPlayAudio(obj.audioSrc)
        }
      },
      // 声音2
      {
        className: 'sound',
        img: 'common/soundButton',
        styleObj: {
          top: '12%',
          left: '51.8%'
        },
        audioSrc: `case2/P${num}-02`,
        onClick: function (obj) {
          that.doPlayAudio(obj.audioSrc)
        }
      },
    ]
  })
}
const caseList = {
  pages: [
    // 封面
    {
      leftSubject: 'case2/P0-01',
      rightSubject: 'case2/P0-02',
      showPageText: ''
    },
    // 目录
    {
      leftSubject: 'case2/P1-01',
      rightSubject: 'case2/P1-02',
      showPageText: '',
      hotmap: catalogueList
    }
  ]
}
caseList.pages = [...caseList.pages, ...pageItems]
// 特殊设置
// 第13课
caseList.pages[14].hotmap[2] = {
  className: 'sound',
  img: 'common/soundButton',
  styleObj: {
    top: '12%',
    left: '11.8%'
  },
  audioSrc: `case2/P14-01`,
  onClick: function (obj) {
    that.doPlayAudio(obj.audioSrc)
  }
}
caseList.pages[14].hotmap[3] = {
  className: 'sound',
  img: 'common/soundButton',
  styleObj: {
    top: '12%',
    left: '50.8%'
  },
  audioSrc: `case2/P14-02`,
  onClick: function (obj) {
    that.doPlayAudio(obj.audioSrc)
  }
}
caseList.pages[14].hotmap[4] = {
  className: 'sound',
  img: 'common/soundButton',
  styleObj: {
    top: '60.5%',
    left: '11.8%'
  },
  audioSrc: `case2/P14-03`,
  onClick: function (obj) {
    that.doPlayAudio(obj.audioSrc)
  }
}
caseList.pages[14].hotmap[5] = {
  className: 'sound',
  img: 'common/soundButton',
  styleObj: {
    top: '36.5%',
    left: '11.8%'
  },
  audioSrc: `case2/P14-04`,
  onClick: function (obj) {
    that.doPlayAudio(obj.audioSrc)
  }
}
// 第20课
caseList.pages[21].hotmap[2] = {
  className: 'sound',
  img: 'common/soundButton',
  styleObj: {
    top: '12%',
    left: '11.8%'
  },
  audioSrc: `case2/P21-01`,
  onClick: function (obj) {
    that.doPlayAudio(obj.audioSrc)
  }
}
caseList.pages[21].hotmap[3] = {
  className: 'sound',
  img: 'common/soundButton',
  styleObj: {
    top: '12%',
    left: '50.8%'
  },
  audioSrc: `case2/P21-02`,
  onClick: function (obj) {
    that.doPlayAudio(obj.audioSrc)
  }
}
caseList.pages[21].hotmap[4] = {
  className: 'sound',
  img: 'common/soundButton',
  styleObj: {
    top: '55.5%',
    left: '50.8%'
  },
  audioSrc: `case2/P21-03`,
  onClick: function (obj) {
    that.doPlayAudio(obj.audioSrc)
  }
}
caseList.pages[21].hotmap[5] = {
  className: 'sound',
  img: 'common/soundButton',
  styleObj: {
    top: '72.5%',
    left: '50.8%'
  },
  audioSrc: `case2/P21-04`,
  onClick: function (obj) {
    that.doPlayAudio(obj.audioSrc)
  }
}
console.log(caseList.pages)
export function getCase (currentThis) {
  that = currentThis
  return caseList
}